package org.xiaoxin.onecoupon.framework.config;

import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.xiaoxin.onecoupon.framework.idempotent.NoDuplicateSubmitAspect;
import org.xiaoxin.onecoupon.framework.idempotent.NoMQDuplicateConsumeAspect;

/**
 * 幂等组件相关配置类
 * @author xiaoxin
 * 2025/4/17
 */
public class IdempotentConfiguration {
   /**
    * 防止用户重复提交表单信息切面控制器
    */
   @Bean
   public NoDuplicateSubmitAspect noDuplicateSubmitAspect(RedissonClient redissonClient) {
      return new NoDuplicateSubmitAspect(redissonClient);
   }
   /**
    * 防止消息队列消费者重复消费消息切面控制器
    */
   @Bean
   public NoMQDuplicateConsumeAspect noMQDuplicateConsumeAspect(StringRedisTemplate stringRedisTemplate) {
      return new NoMQDuplicateConsumeAspect(stringRedisTemplate);
   }
}
